<template>
  <div class="app-container">
    <div class="head">
      <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
        <el-form-item label="" prop="">
          <el-input v-model="queryParams.keyword" placeholder="权益卡名称/发行方" clearable/>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="listBox">
      <div class="listBox_head">
        <export-excel-button title="id分配列表" action="/equityManager/inventory/export" :params="ExportParams" />
        <el-button type="primary" @click="handleUpdate(1)" :disabled="productIds.length>0?false:true">发行库存调整</el-button>
        <el-button type="primary" @click="handleUpdate(2)" :disabled="productIds.length>0?false:true">盲盒库存调整</el-button>
        <el-button type="primary" @click="handleUpdate(3)" :disabled="productIds.length>0?false:true">兑换库存调整</el-button>
        <el-button type="primary" @click="handleUpdate(4)" :disabled="productIds.length>0?false:true">合成库存调整</el-button>
        <el-button type="primary" @click="handleUpdate(5)" :disabled="productIds.length>0?false:true">数字宝箱库存调整</el-button>
      </div>
      <el-table ref="multipleTable" v-loading="loading" :data="tableList" stripe border row-key="id"
        @selection-change="handleSelectionChange">
        <el-table-column type="selection" :reserve-selection="true" width="55" fixed="left">
        </el-table-column>
        <el-table-column label="序号" align="center" type="index" width="64px" fixed="left" />
        <el-table-column label="权益卡名称" align="center" prop="cardName" :show-overflow-tooltip="true" width="120" fixed="left"/>
        <el-table-column label="发行方" align="center" prop="name" :show-overflow-tooltip="true" width="120" fixed="left" />
        <el-table-column label="铸造数量" align="center" prop="issueTotal" width="120" />
        <el-table-column label="未分配数量" align="center" prop="usable" width="120" />
        <el-table-column label="激活数量" align="center" prop="medalInventory" width="120" />
        <el-table-column label="发行分配库存" align="center" prop="issueAllotInventory" width="120" />
        <el-table-column label="发行锁定库存" align="center" prop="issueLockInventory" width="120" />
        <el-table-column label="已售数量" align="center" prop="issueSellInventory" />
        <el-table-column label="神椰库存" align="center" prop="issueShenyeInventory" width="120" />
        <el-table-column label="发行可释放库存" align="center" prop="issueReleaseInventory" width="120" />
        <el-table-column label="盲盒分配库存" align="center" prop="boxAllotInventory" width="120" />
        <el-table-column label="盲盒锁定库存" align="center" prop="boxLockInventory" width="120" />
        <el-table-column label="抽取数量" align="center" prop="boxExtractInventory" width="120" />
        <el-table-column label="盲盒剩余库存" align="center" prop="boxSurplusInventory" width="120" />
        <el-table-column label="可释放库存" align="center" prop="boxReleaseInventory" width="120" />
        <el-table-column label="已空投数量" align="center" prop="airdropInventory" width="120" />
        <el-table-column label="兑换分配库存" align="center" prop="changeAllotInventory" width="120" />
        <el-table-column label="兑换锁定库存" align="center" prop="changeLockInventory" width="120" />
        <el-table-column label="已兑数量" align="center" prop="changeInventory" width="120" />
        <el-table-column label="兑换剩余库存" align="center" prop="changeSurplusInventory" width="120" />
        <el-table-column label="兑换可释放库存" align="center" prop="changeReleaseInventory" width="120" />

        <el-table-column label="合成分配库存" align="center" prop="castingAllotInventory" width="120" />
        <el-table-column label="合成锁定库存" align="center" prop="castingLockInventory" width="120" />
        <el-table-column label="合成数量" align="center" prop="castingInventory" width="120" />
        <el-table-column label="合成剩余库存" align="center" prop="castingSurplusInventory" width="120" />
        <el-table-column label="合成可释放数量" align="center" prop="castingReleaseInventory" width="120" />

        <el-table-column label="宝箱分配库存" align="center" prop="treasureBoxInventory" width="120" />
        <el-table-column label="宝箱锁定库存" align="center" prop="treasureBoxLockInventory" width="120" />
        <el-table-column label="未发数量" align="center" prop="treasureBoxUnSendInventory" width="120" />
        <el-table-column label="已发数量" align="center" prop="treasureBoxSendInventory" width="120" />
        <el-table-column label="剩余数量" align="center" prop="treasureBoxSurplusInventory" width="120" />
        <el-table-column label="宝箱可释放数量" align="center" prop="treasureBoxReleaseInventory" width="120" />
        <!-- <el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width" fixed="right">
          <template slot-scope="scope">
            <el-button size="mini" type="text" @click="handleUpdate(scope.row,1)">发行库存调整</el-button>
            <el-button size="mini" type="text" @click="handleUpdate(scope.row,2)">盲盒库存调整</el-button>
            <el-button size="mini" type="text" @click="handleUpdate(scope.row,3)">兑换库存调整</el-button>
          </template>
        </el-table-column> -->
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList" />
    </div>
    <Dialog ref="dialog" @refresh="getList"></Dialog>
  </div>
</template>

<script>
  import {
    inventoryList,
    
  } from "@/api/equityManager/equityCard";
  import Dialog from "@/views/equityManager/idDistribution/dialog";
  import ExportExcelButton from "@/components/ExportExcelButton/index";
  export default {
    // dicts: ['equity_card_issue_type', 'equity_card_sell_status'],
    name: "",
    components: {
      Dialog,
      ExportExcelButton
    },
    data() {
      return {
        //日期
        date: [],
        timeValue: '', //编辑时间
        dialogVisible: false,
        // 遮罩层
        loading: false,
        // 导出遮罩层
        exportLoading: false,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 表格数据
        tableList: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          keyword: '', //查询关键字
        },
        productIds:[],// 选中数组
      };
    },
    computed: {
      ExportParams() {
        const params = {
          ...this.queryParams,
        };
        return params;
      },
    },
    created() {
      this.getList();
      console.log(this.dict)
    },
    methods: {
      /** 查询列表 */
      getList() {
        this.loading = true;
        inventoryList(this.queryParams).then(response => {
          this.tableList = response.result.records;
          this.total = response.result.total;
          this.loading = false;
        });
      },
      // 表单重置
      reset() {
        this.date = []
        this.queryParams = {
          pageNum: 1,
          pageSize: 10,
          keyword: '', //查询关键字
        }
        // this.resetForm("form");
        this.handleQuery()
      },
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.reset();
        this.handleQuery();
        // this.$refs.multipleTable.clearSelection(); //清空表格多选选中状态
      },
      /** 按钮操作 */
      handleUpdate(status) {
        this.$refs.dialog.open(status,this.productIds);
      },
      /** 多选框选中数据 */
      handleSelectionChange(selection) {
        this.productIds = selection.map(item => item.id)
        console.log(this.productIds)
      },
    }
  };

</script>
<style scoped>
  .head {
    box-shadow: 0px 4px 12px 0px rgb(1 41 99 / 6%);
    background-color: #fff;
    border-radius: 8px;
    padding: 20px 20px 0;
  }

  .listBox {
    box-shadow: 0px 4px 12px 0px rgb(1 41 99 / 6%);
    background-color: #fff;
    border-radius: 8px;
    padding: 20px 20px;
    margin-top: 10px;
  }

  .listBox_head {
    width: 100%;
    display: flex;
    align-items: center;
    padding-bottom: 20px;
  }

  .img_box {
    width: 80px;
    height: 80px;
  }

  .time_box {
    cursor: pointer;
  }

  .time_box:hover {
    color: #1890FF;
  }

</style>
